/*
 * Created by SharpDevelop.
 * User: Dror B. Helper
 * Date: 01/10/2008
 * Time: 21:52
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using StackOverflowClient;
using NUnit.Framework;
using StackOverflowClient.Messages;

namespace StackOverflowClientUnitTests
{
	[TestFixture]
	public class ListenerTests
	{
        [Test]
		public void UserReputationChanged_UserReputationUpdated_ReportUserReputationChanger()
		{
			var newUser = new UserDescriptor();
			newUser.Name = "user1";
			newUser.Reputation = 0;
			newUser.NumberOfBadges = 0;
			newUser.Image = string.Empty;
            try
            {
                var listener = new Listner(1000);
                listener.Process(newUser);
                newUser.Reputation = 5;
                listener.Process(newUser);
                Assert.AreEqual(1, listener.MessageQueue.Count);
                var message = listener.MessageQueue.Dequeue();
                Assert.IsTrue(message is ReputationChangedMessage);
            }
            finally
            {
                var archive = new UserArchive();
                archive.Delete(newUser.Name);
            }
		}
	}
}
